package com.bawei.caohao0802.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.caohao0802.model.bean.DengBean
import com.bawei.caohao0802.model.bean.LeiBean
import com.bawei.caohao0802.model.util.HttpUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
 * 作者: 曹浩
 * 时间: 2024/8/2
 * 功能描述:
 */
class MainVewiModel :ViewModel(){
    var dengdata=MutableLiveData<DengBean>()
    fun getdeng(phone:String,pwd:String){
     var map= mutableMapOf<String,String>()
        map.put("userName",phone)
        map.put("passwd",pwd)

        HttpUtils.httpUtils.server.getdeng(map)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe{
                dengdata.value=it
            }
    }
    val leidata = MutableLiveData<LeiBean>()
    fun getlei(
        userId: Int,
        liveType: Int,
        page: Int,
        size: Int
    ){
        HttpUtils.httpUtils.server.getlei(userId, liveType, page, size)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                leidata.value=it
            }
    }
}